﻿/* ****************************************************************************
 *
 * Copyright (c) Jeff Hardy 2007-2009.
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.txt file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * jdhardy@gmail.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * ***************************************************************************/

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Windows.Forms;

namespace NWSGI.ManagementClient
{
    class OsEnvironPage: NwsgiVariableListPage
    {
        protected override IEnumerable<INwsgiConfigItem> GetVariables()
        {
            ArrayList variables = ServiceProxy.GetOsEnviron();
            List<INwsgiConfigItem> items = new List<INwsgiConfigItem>();

            foreach(string[] variable in variables)
            {
                items.Add(new VariableItem(variable));
            }

            return items;
        }

        protected override void AddItem(INwsgiConfigItem value)
        {
            ServiceProxy.AddOsEnvironVariable((VariableItem)value);
        }

        protected override void EditItem(INwsgiConfigItem oldValue, INwsgiConfigItem newValue)
        {
            ServiceProxy.EditOsEnvironVariable((VariableItem)oldValue, (VariableItem)newValue);
        }

        protected override void DeleteItem(INwsgiConfigItem selected)
        {
            ServiceProxy.DeleteOsEnvironVariable((VariableItem)selected);
        }
    }
}
